$(document).ready(function () {

    $('#login-form').validate({
        rules: {
            login: {
                digits: true,
                rangelength: [6, 6],
                required: true,
            },
            password: {
                required: true,
            }
        },
        highlight: function (element) {
            $(element).closest('.form-group').removeClass('has-success').addClass('has-error');
        },
        success: function (element) {
            $(element).closest('.form-group').removeClass('has-error').addClass('has-success');
        }
    });

    $("#change-member-details-form").validate({
        rules: {
            Adres1: {
                required: true,
                maxlength: 34,
            },
            Adres2: {
                maxlength: 34,
            },
            CodPost: {
                required: true,
                maxlength: 5,
            },
            Ville: {
                required: true,
                maxlength: 34,
            },
            Cod_Pays: {
                required: true,
            },
            No_Tel_Dom: {
                required: true,
                maxlength: 20,
            },
            No_Tel_Emp: {
                required: true,
                maxlength: 20,
            },
            No_Tel_GSM: {
                required: true,
                maxlength: 20,
            },
            No_Tel_Conj: {
                required: true,
                maxlength: 20,
            },
            Mail: {
                required: true,
                maxlength: 50,
                email: true,
            },
        },
        highlight: function (element) {
            $(element).closest('.form-group').removeClass('has-success').addClass('has-error');
        },
        success: function (element) {
            $(element).closest('.form-group').removeClass('has-error').addClass('has-success');
        }
    });

    $("#change-member-password-form").validate({
        rules: {
            old_password: {
                required: true,
            },
            new_password1: {
                required: true,
                maxlength: 10,
            },
            new_password2: {
                required: true,
                maxlength: 10,
                equalTo: '#new_password1',
            },
        },
        highlight: function (element) {
            $(element).closest('.form-group').removeClass('has-success').addClass('has-error');
        },
        success: function (element) {
            $(element).closest('.form-group').removeClass('has-error').addClass('has-success');
        }
    });

    $('#search_member-form').validate({
        rules: {
            name: {
                required: true,
                minlength: 2,
            },
        },
        highlight: function (element) {
            $(element).closest('.form-group').removeClass('has-success').addClass('has-error');
        },
        success: function (element) {
            $(element).closest('.form-group').removeClass('has-error').addClass('has-success');
        }
    });

    $('#email_login-form').validate({
        rules: {
            name: {
                minlength: 2,
            },
            birthday: {
                rangelength: [8, 10],
            },
            cnrs_id: {
                digits: true,
                rangelength: [5, 5],
            },
        },
        highlight: function (element) {
            $(element).closest('.form-group').removeClass('has-success').addClass('has-error');
        },
        success: function (element) {
            $(element).closest('.form-group').removeClass('has-error').addClass('has-success');
        }
    });

});
